
package com.guqiang.invocation

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.CompoundButton
import kotlinx.android.synthetic.main.main_activity.*

class MainActivity : AppCompatActivity() {

    companion object {
        var isHooked = false
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main_activity)
//        if (savedInstanceState == null) {
//            supportFragmentManager.beginTransaction()
//                .replace(R.id.container, MainFragment.newInstance())
//                .commitNow()
//        }
        switch1.setOnCheckedChangeListener { buttonView, isChecked ->
            App.hook(isChecked)
            isHooked = isChecked
        }

        button1.setOnClickListener { startActivity(Intent(this@MainActivity,MainActivity1::class.java)) }
        button2.setOnClickListener { startActivity(Intent(this@MainActivity,MainActivity2::class.java)) }

    }

    override fun onResume() {
        super.onResume()
        switch1.isChecked = isHooked
    }
}
